package com.example.demo.service;

import com.example.demo.mapper.LogInfoMapper;
import com.example.demo.model.LogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LogInfoService {
    @Autowired
    private LogInfoMapper logInfoMapper;


    // 如果不加该注解就是普通方法  加上该方法使其成为事务
    // 事务2(实现事务的嵌套)
    @Transactional(propagation = Propagation.REQUIRED)
    public int addLog(LogInfo logInfo) {
//        int num = 10/0;
        return logInfoMapper.addLog(logInfo);
    }





    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public int addLog5(LogInfo logInfo) {
        int num = 10/0;
        return logInfoMapper.addLog(logInfo);
    }





}
